package com.eurasia.firstapp.resources;


import com.eurasia.firstapp.commands.CreateActivityCommand;
import com.eurasia.firstapp.entities.Activity;
import com.eurasia.firstapp.entities.User;
import com.eurasia.firstapp.exceptions.BusinessException;
import com.eurasia.firstapp.services.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("apiActivity")
public class ActivityResource {



    @Autowired
    private ActivityService activityService;

    @GetMapping("selectAllActivity")
    public ResponseEntity selectAllActivity(){
        return new ResponseEntity(activityService.selectAllActivity(), HttpStatus.CREATED);
    }

    @GetMapping("selectActivityByID")
    public ResponseEntity selectActivityByID(@RequestParam int id){
        return new ResponseEntity(activityService.selectActivityByID(id), HttpStatus.CREATED);
    }

    @PostMapping("addActivity")
    public ResponseEntity addActivity(@RequestBody CreateActivityCommand createActivityCommand)throws BusinessException {
        Activity activity = activityService.addActivity(
                createActivityCommand.getTitle(),
                createActivityCommand.getDescribe(),
                createActivityCommand.getClassify(),
                createActivityCommand.getLimitDate(),
                createActivityCommand.getTeamMax(),
                createActivityCommand.getTeamNumber(),
                createActivityCommand.getTeamSum());
        return new ResponseEntity(activity, HttpStatus.CREATED);
    }
}
